library(gridExtra)
library(readstata13)
library(ggplot2)
library(gridExtra)
library(foreign)
library(MASS)
library(Matrix)
library(lattice)
library(rdd)
library(foreign)
library(ri)
library(scales)

rm(list = ls())
setwd("~/Dropbox/Two habits formed hand-in-hand/Two habits formed in the shadow of the voting booth/")




###################
#Figure 2, Panel B#
###################






theme_base1 <- 
  theme_minimal(base_size=15)  + 
  theme(legend.position=c(0.1, .1),  legend.key.size = unit(1,"line"),
        axis.text=element_text(size=16),axis.title.x=element_text(size=14),axis.title.y=element_text(size=16),
        plot.title = element_text(size=16, hjust= 0.5))


data <- read.dta("Data/sameaveragecontrolsInt.dta")



data$grp<-as.factor(data$id)





main<-ggplot(data, aes(x=id, y =estimate)) +   
  geom_point(size = 2,position=position_dodge(0.35)) + 
  geom_errorbar(aes(ymax = max95, ymin = min95),width=0,  size=.7,position=position_dodge(width=0.35))+
  geom_errorbar(aes(ymax = max90, ymin = min90),width=0, size=1.6,position=position_dodge(width=0.35))+
  scale_y_continuous(limits = c(-.07, .15))+ 
  scale_x_continuous(name="Election Type",labels=c("Presidential","All","Midterm"),breaks = c(1,2,3),limits=c(0.75,3.25))+
  geom_hline(yintercept = 0, 
             linetype = 2, color = "black")+ ylab("ITT of Same-Election Eligibles") + xlab("")+
  theme_base1 + ggtitle("Difference in Interest in the Election:\n Same vs different type of election") 
main
ggsave("Graphs/AllaverageInt.pdf", width = 22, height = 18, units = "cm")  






